<include file="common/header_lixin" title="我要卖出" />

<div class="page">
    <div class="page-hd">
        <div class="header bor-1px-b">
    <div class="header-left">
        <a href="javascript:history.go(-1)" class="left-arrow"></a>
    </div>
    <div class="header-title">我要卖出</div>
    <div class="header-right">
        <a href="#"></a>
    </div>
</div>
    </div>

    <div class="page-bd">
        <!-- 页面内容-->
        <form action="{:U('Dcworld/Dcworld/buy_in')}" method="post">
            <input type="hidden"  name="id" value="{$data.id}">
            <div class="weui-cells">
                <div class="weui-cell fs28">
                    <div class="weui-cell__hd">
                        <label class="weui-label">当前ACC</label>
                    </div>
                    <div class="weui-cell__bd text-main">{$user.balance}</div>
                </div>
                <div class="weui-cell fs28">
                    <div class="weui-cell__hd">
                        <label class="weui-label">卖出价格</label>
                    </div>
                    <div class="weui-cell__bd text-gray2">{$data.total_price}<span class="fs28 text-muted">$</span></div>
                </div>
                <div class="weui-cell fs28">
                    <div class="weui-cell__hd">
                        <label class="weui-label">卖出数量</label>
                    </div>
                    <div class="weui-cell__bd text-gray2">{$data.number}<span class="fs28 text-muted">个</span></div>
                </div>
                <div class="weui-cell fs28">
                    <div class="weui-cell__hd">
                        <label class="weui-label">卖出单价</label>
                    </div>
                    <div class="weui-cell__bd text-gray2">{$data.curr_price}<span class="fs28 text-muted">$</span></div>
                </div>
                <div class="weui-cell fs28">
                    <div class="weui-cell__hd">
                        <label class="weui-label">转账方式</label>
                    </div>
                    <div class="weui-cell__bd text-gray2">支付宝</div>
                </div>
            </div>
            <div class="weui-btn-area">
                <a href="javascript:;" onclick="check_form()" class="weui-btn weui-btn_primary">确认购买</a>
            </div>
        </form>

    </div>
</div>


<script>
    $(function() {
        FastClick.attach(document.body);
    });
</script>
<script>

    can_click=1;
    function check_form(){
        $.ajax({
            type : "POST",
            dataType:"JSON",
            url:"/index.php/Acc/Transaction/sell_acc",
            data : $('form').serialize(),// 你的formid
            success: function(res){
                console.log(res);
                if(res.code==0){
                    $.toast("下单成功",1000,function(){
                        window.location.href="/index.php/Acc/Transaction/transaction_center";
                    });
                }else if(res.code==-2){
                    $.toast(res.msg, "forbidden");
                    setTimeout(function(){
                        check_form();
                    },1500);
                }else{
                    if(res.code==2){
                        $.confirm({
                            title: '标题',
                            text: res.msg,
                            onOK: function () {
                                //点击确认
                                window.location.href="/index.php/Dcworld/Member/account_list";
                            },
                            onCancel: function () {
                            }
                        });
                    }else{
                        $.toast(res.msg, "cancel");
                    }
                }
            }
        });

    }
</script>
</body>
</html>